#include <iostream>
#include <map>
#include <cctype>

using namespace std;

int main()
{
    string tmp;
    char a;
    getline(cin, tmp);
    cin >> a;
    if (isupper(a))
    {
        a = a - 'A' + 'a';
    }
    map<char, int> m;
    for (auto e : tmp)
    {
        if (isupper(e))
        {
            e = e - 'A' + 'a';
        }
        m[e]++;
    }
    cout << m[a] << endl;
    return 0;
}
